package File;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ling
 * Date: 2022-08-12
 * Time: 23:52
 */
public class Demo9 {
    public static void main(String[] args) {
        try (OutputStream outputStream = new FileOutputStream("test2.txt",true)) {//开启续写模式
            outputStream.write('h');
            outputStream.write('e');
            outputStream.write('l');
            outputStream.write('l');
            outputStream.write('o');
            // 不要忘记 flush

            outputStream.flush();
            String s="hello java";
            outputStream.write(s.getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
